{% extends 'admin/admin_base.html' %}
{% import 'admin/macro.html' as helper %}
{% block content %}

    <div class="panel panel-default panel-table">
        <div class="panel-heading">
            <div class="row">
                <div class="col col-xs-6">
                    <h3 class="panel-title">导航管理</h3>
                </div>
                <div class="col col-xs-6 text-right">
                    <a type="button"
                       class="btn btn-sm btn-primary btn-create"
                       data-toggle="modal" href="#addMenuModal">新增
                    </a>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <table class="table table-striped table-bordered table-list">
                <thead>
                <tr>
                    <th><em class="fa fa-cog"></em></th>
                    <th class="hidden-xs">ID</th>
                    <th>名称</th>
                    <th>是否显示</th>
                </tr>
                </thead>
                <tbody>
                {% for menu in menulst.items %}
                    <tr>
                        <td align="center">
                            <button onclick="getMenu_info('{{ url_for('admin.menu_get_info',id=menu.id) }}')"
                                    class="btn btn-default"><em
                                    class="fa fa-pencil"></em></button>
                            <button onclick="delMenu('{{ url_for('admin.menu_del',id=menu.id) }}')"
                                    class="btn btn-danger"><em
                                    class="fa fa-trash"></em></button>
                        </td>
                        <td class="hidden-xs">{{ menu.id }}</td>
                        <td>{{ menu.menuName }}</td>
                        <td>
                            <a href="{{ url_for('admin.menus_setvisible',id=menu.id) }}"><span
                                    class="label label-{{ 'danger' if menu.visible else 'success' }}">{{ '隐藏' if menu.visible else '显示' }}</span>
                            </a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>

        </div>
        <div class="panel-footer">
            {{ helper.render_admin_pagination(menulst,'.menus') }}
        </div>
    </div>


    {# 修改菜单modal框 #}

    <div class="modal fade" id="editmodel">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">修改导航</h4>
                </div>
                <form action="{{ url_for('admin.menus_edit') }}" method="POST" role="form" class="form-horizontal"
                      autocomplete="off">
                    {{ editmenuform.hidden_tag() }}
                    <div class="modal-body">
                        <div class="form-group">
                            {{ editmenuform.menuname.label(class_='control-label col-md-offset-2 col-md-2') }}
                            <div class="col-md-4">
                                {{ editmenuform.menuname(class_='form-control') }}
                            </div>
                        </div>
                        <div class="form-group">
                            {{ editmenuform.visibled.label(class_='control-label col-md-offset-2 col-md-2') }}
                            <div class="col-md-4">
                                {{ editmenuform.visibled() }}
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        {{ editmenuform.submit(class_='btn btn-primary') }}
                    </div>

                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    {#新增菜单modal框#}
    <div class="modal fade" id="addMenuModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">&times;
                    </button>
                    <h4 class="modal-title">新增导航菜单</h4>
                </div>
                <form action="{{ url_for('admin.menu_add') }}" method="post" class="form-horizontal"
                      role="form">
                    {{ addmenuform.hidden_tag() }}
                    <div class="modal-body">
                        <div class="form-group">
                            {{ addmenuform.menuname.label(class_='control-label col-md-2 col-md-offset-2') }}
                            <div class="col-md-6">
                                {{ addmenuform.menuname(class_='form-control',required='requeired') }}
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default"
                                data-dismiss="modal">取消
                        </button>
                        {{ addmenuform.submit(class_='btn btn-primary') }}
                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    {#    删除菜单modal框#}
    <div class="modal fade" id="delMenuModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">&times;
                    </button>
                    <h4 class="modal-title">提示</h4>
                </div>
                <div class="modal-body">
                    本导航删除将不可恢复
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>
                    <button id="delMenuClick" type="button"
                            class="btn btn-primary">确定
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
{% endblock %}


